import React,{useEffect, useState} from 'react'
import {useLocation,useParams,useNavigate} from "react-router-dom"
import { NavBar ,Toast} from 'react-vant';
import axios from 'axios'
function Deatil() {
  let navgiate = useNavigate()
  // navgiate(-1) 表示到上一个路由
  let {state} = useLocation()
  let {id} = useParams()

  let [newarr,setNnewArr] = useState([])
  console.log(id);
  useEffect(()=>{
    axios.get("/api/movielist").then(res=>{
       let arr = res.data.filter((item,index)=>{return item.id === id})
    //    console.log(arr);
       setNnewArr(arr)
    })
 },[])
  return (
    <div>
         <NavBar
            title="标题"
            leftText="返回"
            rightText="按钮"
            onClickLeft={() => navgiate(-1)}
            onClickRight={() => Toast('按钮')}
    />
        {/* {
           state ? <div>
               <img src={state.img} alt="" />
               <h4>{state.name}</h4>
           </div> :""
        } */}
        

    </div>
  )
}

export default Deatil